%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/interfaces-relational/nested"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: 6, 8, 9, 10<br />2: PgSelect[7]<br />3: PgSelectRows[11]"):::bucket
    Bucket1("Bucket 1 (listItem)<br />Deps: 10, 6<br /><br />ROOT __Item{1}ᐸ11ᐳ[12]"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 13, 10, 6<br /><br />ROOT PgSelectSingle{1}ᐸpeopleᐳ[13]<br />1: <br />ᐳ: 14, 15<br />2: PgSelect[16]<br />3: PgSelectRows[20]"):::bucket
    Bucket3("Bucket 3 (listItem)<br />Deps: 10<br /><br />ROOT __Item{3}ᐸ20ᐳ[21]"):::bucket
    Bucket4("Bucket 4 (polymorphic)<br />__typename: Lambda[26]<br />Deps: 26, 10, 23, 22, 25, 117"):::bucket
    Bucket5("Bucket 5 (polymorphicPartition)<br />|RelationalTopic<br />Deps: 10, 23, 22, 25, 117<br />ᐳRelationalTopic<br /><br />1: PgSelect[28]<br />2: PgSelectRows[33]<br />ᐳ: First[32], PgSelectSingle[34]"):::bucket
    Bucket6("Bucket 6 (polymorphicPartition)<br />|RelationalPost<br />Deps: 10, 23, 22, 25, 117<br />ᐳRelationalPost<br /><br />1: PgSelect[36]<br />2: PgSelectRows[41]<br />ᐳ: First[40], PgSelectSingle[42]"):::bucket
    Bucket7("Bucket 7 (polymorphicPartition)<br />|RelationalDivider<br />Deps: 10, 23, 22, 25, 117<br />ᐳRelationalDivider<br /><br />1: PgSelect[44]<br />2: PgSelectRows[49]<br />ᐳ: First[48], PgSelectSingle[50]"):::bucket
    Bucket8("Bucket 8 (polymorphicPartition)<br />|RelationalChecklist<br />Deps: 10, 23, 22, 25, 117<br />ᐳRelationalChecklist<br /><br />1: PgSelect[52]<br />2: PgSelectRows[57]<br />ᐳ: First[56], PgSelectSingle[58]"):::bucket
    Bucket9("Bucket 9 (polymorphicPartition)<br />|RelationalChecklistItem<br />Deps: 10, 23, 22, 25, 117<br />ᐳRelationalChecklistItem<br /><br />1: PgSelect[60]<br />2: PgSelectRows[65]<br />ᐳ: First[64], PgSelectSingle[66]"):::bucket
    Bucket10("Bucket 10 (combined)<br />Deps: 22, 10<br /><br />1: <br />ᐳ: PgClassExpression[67]<br />2: PgSelect[68]<br />3: PgSelectRows[73]<br />ᐳ: 72, 74, 122, 124, 125, 176"):::bucket
    Bucket11("Bucket 11 (polymorphic)<br />__typename: Lambda[125]<br />Deps: 125, 10, 122, 124, 176"):::bucket
    Bucket12("Bucket 12 (polymorphicPartition)<br />|RelationalTopic<br />Deps: 10, 122, 124, 176<br />(5) ...ᐳRelationalTopic<br /><br />1: PgSelect[127]<br />2: PgSelectRows[132]<br />ᐳ: First[131], PgSelectSingle[133]"):::bucket
    Bucket13("Bucket 13 (polymorphicPartition)<br />|RelationalPost<br />Deps: 10, 122, 124, 176<br />(5) ...ᐳRelationalPost<br /><br />1: PgSelect[135]<br />2: PgSelectRows[140]<br />ᐳ: First[139], PgSelectSingle[141]"):::bucket
    Bucket14("Bucket 14 (polymorphicPartition)<br />|RelationalDivider<br />Deps: 10, 122, 124, 176<br />(5) ...ᐳRelationalDivider<br /><br />1: PgSelect[143]<br />2: PgSelectRows[148]<br />ᐳ: First[147], PgSelectSingle[149]"):::bucket
    Bucket15("Bucket 15 (polymorphicPartition)<br />|RelationalChecklist<br />Deps: 10, 122, 124, 176<br />(5) ...ᐳRelationalChecklist<br /><br />1: PgSelect[151]<br />2: PgSelectRows[156]<br />ᐳ: First[155], PgSelectSingle[157]"):::bucket
    Bucket16("Bucket 16 (polymorphicPartition)<br />|RelationalChecklistItem<br />Deps: 10, 122, 124, 176<br />(5) ...ᐳRelationalChecklistItem<br /><br />1: PgSelect[159]<br />2: PgSelectRows[164]<br />ᐳ: First[163], PgSelectSingle[165]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket2
    Bucket2 --> Bucket3
    Bucket3 --> Bucket4
    Bucket4 --> Bucket5 & Bucket6 & Bucket7 & Bucket8 & Bucket9
    Bucket5 --> Bucket10
    Bucket6 --> Bucket10
    Bucket7 --> Bucket10
    Bucket8 --> Bucket10
    Bucket9 --> Bucket10
    Bucket10 --> Bucket11
    Bucket11 --> Bucket12 & Bucket13 & Bucket14 & Bucket15 & Bucket16

    %% plan dependencies
    PgSelect7[["PgSelect[7∈0] ➊<br />ᐸpeopleᐳ<br />More deps:<br />- Object[10]<br />- Constantᐸundefinedᐳ[6]"]]:::plan
    Object10{{"Object[10∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ<br />Dependents: 13"}}:::plan
    Access8{{"Access[8∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access9{{"Access[9∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access8 & Access9 --> Object10
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access8
    __Value2 --> Access9
    PgSelectRows11[["PgSelectRows[11∈0] ➊"]]:::plan
    PgSelect7 --> PgSelectRows11
    __Item12[/"__Item[12∈1]<br />ᐸ11ᐳ"\]:::itemplan
    PgSelectRows11 ==> __Item12
    PgSelectSingle13{{"PgSelectSingle[13∈1]<br />ᐸpeopleᐳ"}}:::plan
    __Item12 --> PgSelectSingle13
    PgSelect16[["PgSelect[16∈2]<br />ᐸrelational_itemsᐳ<br />More deps:<br />- Object[10]<br />- Constantᐸundefinedᐳ[6]<br />- Constantᐸundefinedᐳ[6]"]]:::plan
    PgClassExpression15{{"PgClassExpression[15∈2]<br />ᐸ__people__.”person_id”ᐳ"}}:::plan
    PgClassExpression15 --> PgSelect16
    PgClassExpression14{{"PgClassExpression[14∈2]<br />ᐸ__people__.”username”ᐳ"}}:::plan
    PgSelectSingle13 --> PgClassExpression14
    PgSelectSingle13 --> PgClassExpression15
    PgSelectRows20[["PgSelectRows[20∈2]"]]:::plan
    PgSelect16 --> PgSelectRows20
    __Item21[/"__Item[21∈3]<br />ᐸ20ᐳ"\]:::itemplan
    PgSelectRows20 ==> __Item21
    PgSelectSingle22{{"PgSelectSingle[22∈3]<br />ᐸrelational_itemsᐳ"}}:::plan
    __Item21 --> PgSelectSingle22
    PgClassExpression23{{"PgClassExpression[23∈3]<br />ᐸ__relation...ems__.”id”ᐳ"}}:::plan
    PgSelectSingle22 --> PgClassExpression23
    PgClassExpression25{{"PgClassExpression[25∈3]<br />ᐸ__relation...s__.”type”ᐳ"}}:::plan
    PgSelectSingle22 --> PgClassExpression25
    Lambda26{{"Lambda[26∈3]<br />ᐸrelationalItemTypeNameFromTypeᐳ"}}:::plan
    PgClassExpression25 --> Lambda26
    PgClassExpression117{{"PgClassExpression[117∈3]<br />ᐸ__relation...__.”type2”ᐳ"}}:::plan
    PgSelectSingle22 --> PgClassExpression117
    PgSelect28[["PgSelect[28∈5]<br />ᐸrelational_topicsᐳ<br />ᐳRelationalTopic<br />More deps:<br />- Object[10]"]]:::plan
    PgClassExpression23 --> PgSelect28
    First32{{"First[32∈5]^"}}:::plan
    PgSelectRows33[["PgSelectRows[33∈5]^"]]:::plan
    PgSelectRows33 --> First32
    PgSelect28 --> PgSelectRows33
    PgSelectSingle34{{"PgSelectSingle[34∈5]^<br />ᐸrelational_topicsᐳ"}}:::plan
    First32 --> PgSelectSingle34
    PgSelect36[["PgSelect[36∈6]<br />ᐸrelational_postsᐳ<br />ᐳRelationalPost<br />More deps:<br />- Object[10]"]]:::plan
    PgClassExpression23 --> PgSelect36
    First40{{"First[40∈6]^"}}:::plan
    PgSelectRows41[["PgSelectRows[41∈6]^"]]:::plan
    PgSelectRows41 --> First40
    PgSelect36 --> PgSelectRows41
    PgSelectSingle42{{"PgSelectSingle[42∈6]^<br />ᐸrelational_postsᐳ"}}:::plan
    First40 --> PgSelectSingle42
    PgSelect44[["PgSelect[44∈7]<br />ᐸrelational_dividersᐳ<br />ᐳRelationalDivider<br />More deps:<br />- Object[10]"]]:::plan
    PgClassExpression23 --> PgSelect44
    First48{{"First[48∈7]^"}}:::plan
    PgSelectRows49[["PgSelectRows[49∈7]^"]]:::plan
    PgSelectRows49 --> First48
    PgSelect44 --> PgSelectRows49
    PgSelectSingle50{{"PgSelectSingle[50∈7]^<br />ᐸrelational_dividersᐳ"}}:::plan
    First48 --> PgSelectSingle50
    PgSelect52[["PgSelect[52∈8]<br />ᐸrelational_checklistsᐳ<br />ᐳRelationalChecklist<br />More deps:<br />- Object[10]"]]:::plan
    PgClassExpression23 --> PgSelect52
    First56{{"First[56∈8]^"}}:::plan
    PgSelectRows57[["PgSelectRows[57∈8]^"]]:::plan
    PgSelectRows57 --> First56
    PgSelect52 --> PgSelectRows57
    PgSelectSingle58{{"PgSelectSingle[58∈8]^<br />ᐸrelational_checklistsᐳ"}}:::plan
    First56 --> PgSelectSingle58
    PgSelect60[["PgSelect[60∈9]<br />ᐸrelational_checklist_itemsᐳ<br />ᐳRelationalChecklistItem<br />More deps:<br />- Object[10]"]]:::plan
    PgClassExpression23 --> PgSelect60
    First64{{"First[64∈9]^"}}:::plan
    PgSelectRows65[["PgSelectRows[65∈9]^"]]:::plan
    PgSelectRows65 --> First64
    PgSelect60 --> PgSelectRows65
    PgSelectSingle66{{"PgSelectSingle[66∈9]^<br />ᐸrelational_checklist_itemsᐳ"}}:::plan
    First64 --> PgSelectSingle66
    PgSelect68[["PgSelect[68∈10]<br />ᐸrelational_itemsᐳ<br />More deps:<br />- Object[10]"]]:::plan
    PgClassExpression67{{"PgClassExpression[67∈10]<br />ᐸ__relation...parent_id”ᐳ"}}:::plan
    PgClassExpression67 --> PgSelect68
    PgSelectSingle22 --> PgClassExpression67
    First72{{"First[72∈10]"}}:::plan
    PgSelectRows73[["PgSelectRows[73∈10]"]]:::plan
    PgSelectRows73 --> First72
    PgSelect68 --> PgSelectRows73
    PgSelectSingle74{{"PgSelectSingle[74∈10]<br />ᐸrelational_itemsᐳ"}}:::plan
    First72 --> PgSelectSingle74
    PgClassExpression122{{"PgClassExpression[122∈10]<br />ᐸ__relation...ems__.”id”ᐳ<br />ᐳRelationalTopic<br />ᐳRelationalPost<br />ᐳRelationalDivider<br />ᐳRelationalChecklist<br />ᐳRelationalChecklistItem"}}:::plan
    PgSelectSingle74 --> PgClassExpression122
    PgClassExpression124{{"PgClassExpression[124∈10]<br />ᐸ__relation...s__.”type”ᐳ<br />ᐳRelationalTopic<br />ᐳRelationalPost<br />ᐳRelationalDivider<br />ᐳRelationalChecklist<br />ᐳRelationalChecklistItem"}}:::plan
    PgSelectSingle74 --> PgClassExpression124
    Lambda125{{"Lambda[125∈10]^<br />ᐸrelationalItemTypeNameFromTypeᐳ"}}:::plan
    PgClassExpression124 --> Lambda125
    PgClassExpression176{{"PgClassExpression[176∈10]<br />ᐸ__relation...__.”type2”ᐳ<br />ᐳRelationalTopic<br />ᐳRelationalPost<br />ᐳRelationalDivider<br />ᐳRelationalChecklist<br />ᐳRelationalChecklistItem"}}:::plan
    PgSelectSingle74 --> PgClassExpression176
    PgSelect127[["PgSelect[127∈12]<br />ᐸrelational_topicsᐳ<br />(5) ...ᐳRelationalTopic<br />More deps:<br />- Object[10]"]]:::plan
    PgClassExpression122 --> PgSelect127
    First131{{"First[131∈12]^"}}:::plan
    PgSelectRows132[["PgSelectRows[132∈12]^"]]:::plan
    PgSelectRows132 --> First131
    PgSelect127 --> PgSelectRows132
    PgSelectSingle133{{"PgSelectSingle[133∈12]^<br />ᐸrelational_topicsᐳ"}}:::plan
    First131 --> PgSelectSingle133
    PgSelect135[["PgSelect[135∈13]<br />ᐸrelational_postsᐳ<br />(5) ...ᐳRelationalPost<br />More deps:<br />- Object[10]"]]:::plan
    PgClassExpression122 --> PgSelect135
    First139{{"First[139∈13]^"}}:::plan
    PgSelectRows140[["PgSelectRows[140∈13]^"]]:::plan
    PgSelectRows140 --> First139
    PgSelect135 --> PgSelectRows140
    PgSelectSingle141{{"PgSelectSingle[141∈13]^<br />ᐸrelational_postsᐳ"}}:::plan
    First139 --> PgSelectSingle141
    PgSelect143[["PgSelect[143∈14]<br />ᐸrelational_dividersᐳ<br />(5) ...ᐳRelationalDivider<br />More deps:<br />- Object[10]"]]:::plan
    PgClassExpression122 --> PgSelect143
    First147{{"First[147∈14]^"}}:::plan
    PgSelectRows148[["PgSelectRows[148∈14]^"]]:::plan
    PgSelectRows148 --> First147
    PgSelect143 --> PgSelectRows148
    PgSelectSingle149{{"PgSelectSingle[149∈14]^<br />ᐸrelational_dividersᐳ"}}:::plan
    First147 --> PgSelectSingle149
    PgSelect151[["PgSelect[151∈15]<br />ᐸrelational_checklistsᐳ<br />(5) ...ᐳRelationalChecklist<br />More deps:<br />- Object[10]"]]:::plan
    PgClassExpression122 --> PgSelect151
    First155{{"First[155∈15]^"}}:::plan
    PgSelectRows156[["PgSelectRows[156∈15]^"]]:::plan
    PgSelectRows156 --> First155
    PgSelect151 --> PgSelectRows156
    PgSelectSingle157{{"PgSelectSingle[157∈15]^<br />ᐸrelational_checklistsᐳ"}}:::plan
    First155 --> PgSelectSingle157
    PgSelect159[["PgSelect[159∈16]<br />ᐸrelational_checklist_itemsᐳ<br />(5) ...ᐳRelationalChecklistItem<br />More deps:<br />- Object[10]"]]:::plan
    PgClassExpression122 --> PgSelect159
    First163{{"First[163∈16]^"}}:::plan
    PgSelectRows164[["PgSelectRows[164∈16]^"]]:::plan
    PgSelectRows164 --> First163
    PgSelect159 --> PgSelectRows164
    PgSelectSingle165{{"PgSelectSingle[165∈16]^<br />ᐸrelational_checklist_itemsᐳ"}}:::plan
    First163 --> PgSelectSingle165

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect7,Access8,Access9,Object10,PgSelectRows11 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,__Item12,PgSelectSingle13 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2,PgClassExpression14,PgClassExpression15,PgSelect16,PgSelectRows20 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3,__Item21,PgSelectSingle22,PgClassExpression23,PgClassExpression25,Lambda26,PgClassExpression117 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4 bucket4
    classDef bucket5 stroke:#7fff00
    class Bucket5,PgSelect28,First32,PgSelectRows33,PgSelectSingle34 bucket5
    classDef bucket6 stroke:#ff1493
    class Bucket6,PgSelect36,First40,PgSelectRows41,PgSelectSingle42 bucket6
    classDef bucket7 stroke:#808000
    class Bucket7,PgSelect44,First48,PgSelectRows49,PgSelectSingle50 bucket7
    classDef bucket8 stroke:#dda0dd
    class Bucket8,PgSelect52,First56,PgSelectRows57,PgSelectSingle58 bucket8
    classDef bucket9 stroke:#ff0000
    class Bucket9,PgSelect60,First64,PgSelectRows65,PgSelectSingle66 bucket9
    classDef bucket10 stroke:#ffff00
    class Bucket10,PgClassExpression67,PgSelect68,First72,PgSelectRows73,PgSelectSingle74,PgClassExpression122,PgClassExpression124,Lambda125,PgClassExpression176 bucket10
    classDef bucket11 stroke:#00ffff
    class Bucket11 bucket11
    classDef bucket12 stroke:#4169e1
    class Bucket12,PgSelect127,First131,PgSelectRows132,PgSelectSingle133 bucket12
    classDef bucket13 stroke:#3cb371
    class Bucket13,PgSelect135,First139,PgSelectRows140,PgSelectSingle141 bucket13
    classDef bucket14 stroke:#a52a2a
    class Bucket14,PgSelect143,First147,PgSelectRows148,PgSelectSingle149 bucket14
    classDef bucket15 stroke:#ff00ff
    class Bucket15,PgSelect151,First155,PgSelectRows156,PgSelectSingle157 bucket15
    classDef bucket16 stroke:#f5deb3
    class Bucket16,PgSelect159,First163,PgSelectRows164,PgSelectSingle165 bucket16

